﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:Button="clr-namespace:myManga_App.Resources.Theme.Buttons"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:mangaObjects="clr-namespace:myMangaSiteExtension.Objects;assembly=myMangaSiteExtension"
    xmlns:Converters="clr-namespace:myManga_App.Converters"
    xmlns:ObjectViews="clr-namespace:myManga_App.Views.ObjectViews"
    x:Class="myManga_App.Views.HomeView_List"
    x:Name="userControl"
    mc:Ignorable="d" 
    d:DesignHeight="400"
    d:DesignWidth="600"
    Background="{DynamicResource window-background}" 
    Foreground="{DynamicResource window-foreground}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/myManga;component/Resources/Localization/Dictionary_en-US.xaml"/>
                <ResourceDictionary Source="/myManga;component/Themes/CoreResourceDictionary.xaml"/>
                <ResourceDictionary Source="/myManga;component/Themes/Button/MetroButton.xaml"/>
                <ResourceDictionary Source="/myManga;component/Themes/TextBox/TextBox.xaml"/>

                <ResourceDictionary Source="/myManga;component/Themes/ListBox/ListBoxes.xaml"/>
                <ResourceDictionary Source="/myManga;component/Themes/ListBox/ListBoxItems.xaml"/>
                <ResourceDictionary Source="/myManga;component/Themes/ScrollBar/ScrollBar.xaml"/>

                <ResourceDictionary Source="/myManga;component/Themes/ProgressBar/Spinner.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Converters:LoadImageFromMangaArchive x:Key="LoadImageFromMangaArchive"/>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100" MaxWidth="300"/>
            <ColumnDefinition Width="15"/>
            <ColumnDefinition Width="3*"/>
        </Grid.ColumnDefinitions>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="32px"/>
                <RowDefinition/>
                <RowDefinition Height="32px"/>
            </Grid.RowDefinitions>
            <Border 
				Grid.Row="0"
				TextElement.FontSize="16">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.InputBindings>
                        <KeyBinding Command="{Binding SearchSiteCommand}" Key="Return"/>
                        <KeyBinding Command="{Binding ClearSearchCommand}" Key="Esc"/>
                    </Grid.InputBindings>
                    <Button:MetroButton
						Grid.Column="0"
						FontFamily="{DynamicResource OpenIconic}"
						Content="{DynamicResource oi-magnifying-glass}"
						Command="{Binding SearchSiteCommand}"
						ToolTip="Search Sites"
						Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"/>
                    <TextBox
						x:Name="SearchBox"
						Grid.Column="1" 
						BorderBrush="{x:Null}" 
						BorderThickness="0" 
						Background="{x:Null}"
						VerticalContentAlignment="Center"
						Text="{Binding SearchFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <Button:MetroToggleButton 
						x:Name="AdvSrchBtn"
						Grid.Column="2"
						Content="{DynamicResource fa-sort-down}"
						FontFamily="{DynamicResource FontAwesome}"
						ToolTip="Advanced Search" Visibility="Collapsed"/>
                    <Popup 
						PopupAnimation="Slide" 
						PlacementTarget="{Binding ElementName=AdvSrchBtn}"
						IsOpen="{Binding IsChecked, ElementName=AdvSrchBtn}"
						StaysOpen="False">
                        <Border
							BorderThickness="1" 
							BorderBrush="{DynamicResource window-theme-primary}" 
							Background="{DynamicResource window-background}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Button:MetroToggleButton Content="Action" Grid.Column="0" Grid.Row="0"/>
                                <Button:MetroToggleButton Content="Adventure" Grid.Column="1" Grid.Row="0"/>
                                <Button:MetroToggleButton Content="Comedy" Grid.Column="2" Grid.Row="0"/>
                                <Button:MetroToggleButton Content="Demons" Grid.Column="3" Grid.Row="0"/>
                                <Button:MetroToggleButton Content="Drama" Grid.Column="4" Grid.Row="0"/>

                                <Button:MetroToggleButton Content="Ecchi" Grid.Column="0" Grid.Row="1"/>
                                <Button:MetroToggleButton Content="Fantasy" Grid.Column="1" Grid.Row="1"/>
                                <Button:MetroToggleButton Content="Gender Bender" Grid.Column="2" Grid.Row="1"/>
                                <Button:MetroToggleButton Content="Harem" Grid.Column="3" Grid.Row="1"/>
                                <Button:MetroToggleButton Content="Historical" Grid.Column="4" Grid.Row="1"/>

                                <Button:MetroToggleButton Content="Horror" Grid.Column="0" Grid.Row="2"/>
                                <Button:MetroToggleButton Content="Josei" Grid.Column="1" Grid.Row="2"/>
                                <Button:MetroToggleButton Content="Magic" Grid.Column="2" Grid.Row="2"/>
                                <Button:MetroToggleButton Content="Martial Arts" Grid.Column="3" Grid.Row="2"/>
                                <Button:MetroToggleButton Content="Mature" Grid.Column="4" Grid.Row="2"/>

                                <Button:MetroToggleButton Content="Mecha" Grid.Column="0" Grid.Row="3"/>
                                <Button:MetroToggleButton Content="Military" Grid.Column="1" Grid.Row="3"/>
                                <Button:MetroToggleButton Content="Mystery" Grid.Column="2" Grid.Row="3"/>
                                <Button:MetroToggleButton Content="One Shot" Grid.Column="3" Grid.Row="3"/>
                                <Button:MetroToggleButton Content="Psychological" Grid.Column="4" Grid.Row="3"/>

                                <Button:MetroToggleButton Content="Romance" Grid.Column="0" Grid.Row="4"/>
                                <Button:MetroToggleButton Content="School Life" Grid.Column="1" Grid.Row="4"/>
                                <Button:MetroToggleButton Content="Sci-Fi" Grid.Column="2" Grid.Row="4"/>
                                <Button:MetroToggleButton Content="Seinen" Grid.Column="3" Grid.Row="4"/>
                                <Button:MetroToggleButton Content="Shoujo" Grid.Column="4" Grid.Row="4"/>

                                <Button:MetroToggleButton Content="Shoujoai" Grid.Column="0" Grid.Row="5"/>
                                <Button:MetroToggleButton Content="Shounen" Grid.Column="1" Grid.Row="5"/>
                                <Button:MetroToggleButton Content="Shounenai" Grid.Column="2" Grid.Row="5"/>
                                <Button:MetroToggleButton Content="Slice of Life" Grid.Column="3" Grid.Row="5"/>
                                <Button:MetroToggleButton Content="Smut" Grid.Column="4" Grid.Row="5"/>

                                <Button:MetroToggleButton Content="Sports" Grid.Column="0" Grid.Row="6"/>
                                <Button:MetroToggleButton Content="Super Power" Grid.Column="1" Grid.Row="6"/>
                                <Button:MetroToggleButton Content="Supernatural" Grid.Column="2" Grid.Row="6"/>
                                <Button:MetroToggleButton Content="Tragedy" Grid.Column="3" Grid.Row="6"/>
                                <Button:MetroToggleButton Content="Vampire" Grid.Column="4" Grid.Row="6"/>

                                <Button:MetroToggleButton Content="Yaoi" Grid.Column="0" Grid.Row="7"/>
                                <Button:MetroToggleButton Content="Yuri" Grid.Column="1" Grid.Row="7"/>
                                <Button:MetroButton Content="Clear" Grid.Column="4" Grid.Row="7"/>
                            </Grid>
                        </Border>
                    </Popup>
                    <Button:MetroButton
						Grid.Column="3"
					    FontFamily="{DynamicResource OpenIconic}"
					    Content="{DynamicResource oi-delete}"
						Command="{Binding ClearSearchCommand}"
						ToolTip="Clear Search"
						Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"/>
                </Grid>
            </Border>
            <ListBox
				x:Name="MangaObjectItems"
				Grid.Row="1"
				BorderThickness="0" 
				ItemContainerStyle="{DynamicResource HomeView_List_MangaListBoxItem}"
				ScrollViewer.HorizontalScrollBarVisibility="Disabled"
				SelectedItem="{Binding SelectedMangaArchive}"
                SelectedIndex="0"
                ItemsSource="{Binding Path=MangaArchiveCacheCollection, Mode=OneWay, Source={x:Static Application.Current}, UpdateSourceTrigger=PropertyChanged}"/>
            <ProgressBar 
				Grid.Row="1" 
				HorizontalAlignment="Center" 
				VerticalAlignment="Center" 
				Width="96" Height="96" 
				Style="{DynamicResource Spinner}" 
				Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"
                Foreground="#BF000000"/>
            <Button:MetroButton
				Grid.Row="3"
				FontSize="16"
				FontFamily="{DynamicResource OpenIconic}"
				Content="{DynamicResource oi-reload}"
				ContentStringFormat="{}{0} Refresh"
				Command="{Binding RefreshMangaListCommand}"/>
        </Grid>
        <ObjectViews:MangaObjectView 
			x:Name="MangaObjectDescription"
            Grid.Column="2" 
            DataContext="{Binding SelectedItem, ElementName=MangaObjectItems}"/>
        <Border
			HorizontalAlignment="Center" 
			VerticalAlignment="Top"
            BorderBrush="{DynamicResource window-theme-primary}"
            BorderThickness="1,1,1,0"
            Margin="0,-33,0,0"
            Grid.ColumnSpan="3">
            <StackPanel 
                Orientation="Horizontal"
			    Grid.Column="2">
                <Button:MetroButton
			        FontFamily="{DynamicResource OpenIconic}"
			        Content="{DynamicResource oi-reload}"
			        Command="{Binding RefreshMangaCommand}"
			        Height="32"
			        Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"/>
                <Button:MetroButton
			        FontFamily="{DynamicResource OpenIconic}"
			        Content="{DynamicResource oi-trash}"
			        Command="{Binding DeleteMangaCommand}"
			        Height="32"
			        Width="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
